package hgz.stu.review.mock;

import org.junit.Test;
import org.junit.runner.RunWith;

import mockit.Injectable;
import mockit.Mock;
import mockit.MockUp;
import mockit.integration.junit4.JMockit;

@RunWith(JMockit.class)
public class TestMockInterface {// 此处使用Injectable和Mocked为一样的效果
	@Injectable
	SimpleInterface simpleInterface;

	@Test
	public void testUpper() throws Exception {
		SimpleInterface mockInstance = new MockUp<SimpleInterface>() {
			@Mock
			public String getCityName() {
				return "BEIJING(MOCK)";
			}

			@Mock
			public String getAreaName() {
				return "HUABEI(MOCK)";
			}

		}.getMockInstance();

		System.out.println(mockInstance.getCityName());
		System.out.println(mockInstance.getAreaName());
		System.out.println(simpleInterface.getCityName());
		System.out.println(simpleInterface.getAreaName());
		SimpleInterfaceImpl simpleInterfaceImpl = new SimpleInterfaceImpl();
		System.out.println(simpleInterfaceImpl.getCityName());
		System.out.println(simpleInterfaceImpl.getAreaName());
	}
}
